home *** CD-ROM | disk | FTP | other *** search
/ SuperHack / SuperHack CD.bin / CODING / CPP / METAKIT.ZIP / EXAMPLES / CATSEND / MYDLG.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1996-12-09  |  2.2 KB  |  88 lines

  1. //    mydlg.cpp  -  catalog send dialog sample code
  2. //
  3. //    This is a part of the MetaKit library.
  4. //    Copyright (c) 1996 Meta Four Software.
  5. //    All rights reserved.
  6. /////////////////////////////////////////////////////////////////////////////
  7.  
  8. #include "stdafx.h"
  9. #include "CatSend.h"
  10. #include "MyDlg.h"
  11.  
  12. #ifdef _DEBUG
  13. #define new DEBUG_NEW
  14. #undef THIS_FILE
  15. static char THIS_FILE[] = __FILE__;
  16. #endif
  17.  
  18. /////////////////////////////////////////////////////////////////////////////
  19. // CMyDlg dialog
  20.  
  21. CMyDlg::CMyDlg(CWnd* pParent /*=NULL*/)
  22.     : CDialog(CMyDlg::IDD, pParent)
  23. {
  24.     //{{AFX_DATA_INIT(CMyDlg)
  25.         // NOTE: the ClassWizard will add member initialization here
  26.     //}}AFX_DATA_INIT
  27. }
  28.  
  29. void CMyDlg::DoDataExchange(CDataExchange* pDX)
  30. {
  31.     CDialog::DoDataExchange(pDX);
  32.     //{{AFX_DATA_MAP(CMyDlg)
  33.     DDX_Control(pDX, IDC_ADDRESS, m_address);
  34.     DDX_Control(pDX, IDC_PORT, m_port);
  35.     //}}AFX_DATA_MAP
  36. }
  37.  
  38. BEGIN_MESSAGE_MAP(CMyDlg, CDialog)
  39.     //{{AFX_MSG_MAP(CMyDlg)
  40.     ON_BN_CLICKED(IDC_SEND_BTN, OnSendBtn)
  41.     //}}AFX_MSG_MAP
  42. END_MESSAGE_MAP()
  43.  
  44. /////////////////////////////////////////////////////////////////////////////
  45. // [JCW]  This code added for MetaKit CATSEND
  46.  
  47. BOOL CMyDlg::OnInitDialog()
  48. {
  49.     CDialog::OnInitDialog();
  50.  
  51.     m_address.SetWindowText("127.0.0.1");
  52.     m_port.SetWindowText("12345");
  53.     
  54.     return TRUE;  // return TRUE  unless you set the focus to a control
  55. }
  56.  
  57.     // the following lines show how easy it is to become a TCP/IP client
  58. void CMyDlg::OnSendBtn() 
  59. {
  60.     CString s;
  61.     m_port.GetWindowText(s);
  62.     int port = atoi(s);
  63.  
  64.     CString address;
  65.     m_address.GetWindowText(address);
  66.  
  67.     CFileDialog dlg (TRUE, NULL, "*.*");
  68.     if (port > 0 && dlg.DoModal() == IDOK)
  69.     {
  70.         CSocket client;
  71.         VERIFY(client.Create());
  72.         
  73.         if (client.Connect(address, port))
  74.         {
  75.             CSocketFile stream (&client);
  76.  
  77.                 // use the data file without knowing its structure
  78.             c4_Storage storage (dlg.GetPathName(), false);
  79.             storage.SaveToStream(&stream);
  80.         }
  81.         else
  82.             AfxMessageBox("Could not connect to the CATRECV server.");
  83.     }
  84. }
  85.  
  86. /////////////////////////////////////////////////////////////////////////////
  87. // $Id: mydlg.cpp,v 1.2 1996/12/04 14:49:59 jcw Exp $
  88.